Find among Cells
From Documentation
Find a text among cells is a common function. ZK Spreadsheet doesn't have this built-in function, but we can easily build our own with ZSS API.
We list the key method here. For complete code, please refer to the example code project. This method starts finding from the next cell by rows of the current selection. If nothing found, return the current selection. When reaching the end of a sheet, it does not find from the beginning.
protected Range findNext(Sheet sheet, Range currentSelection) {
int lastColumn = Ranges.range(sheet).getDataRegion().getLastColumn();
int lastRow = Ranges.range(sheet).getDataRegion().getLastRow();
String keyword = keywordBox.getValue().trim();
int row = getStartingRow(sheet, currentSelection);
int column = getStartingColumn(sheet, currentSelection);
while (row <= lastRow){
while (column <= lastColumn){
Range cell = Ranges.range(sheet, row, column);
if (cell.getCellData().getType() == CellType.STRING){
if (match(cell.getCellData().getEditText(), keyword)){
return cell;
}
}
column++;
}
column = 0;
row++;
}
return currentSelection;
}
All source code listed in this book is at Github.